package zhongbo.java.air.airingestion.config;

/*
 配置redis Sub订阅监听者Listener
 */

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import zhongbo.java.air.airingestion.listener.PersonalFlightPathSubscriber;
import zhongbo.java.air.airingestion.listener.RedisSubscribeLogChanelListener;


@Slf4j
@Configuration
public class RedisListenerConfig {

    public static String FLIGHT_PATH_CHANELS = "flight_path_chanel";

    public final static String MY_FLIGHT_PATH_CHANEL = "injest_flight_path_wangsicheng";

    @Autowired
    //RedisSubscribeLogChanelListener处理接受的消息
    public void configListener(RedisMessageListenerContainer listenerContainer,
                               RedisSubscribeLogChanelListener logChanelListener,
                               PersonalFlightPathSubscriber personalFlightPathSubscriber) {
        log.info("配置redis监听器");
        //配置RedidLogSubscribeListener监听频道 log_chanel接收消息
        //PatternTopic监听的频道模式
        Topic logTopic = new PatternTopic(FLIGHT_PATH_CHANELS);
        listenerContainer.addMessageListener(logChanelListener, logTopic);

        //配置RedidLogSubscribeListener监听频道 injest_flight_path_wangsichengel接收消息
//        Topic log =new PatternTopic(FLIGHT_PATH_CHANEL);
//        listenerContainer.addMessageListener(personalFlightPathSubscriber,log);
    }

}
